﻿<%


Class Cls_Label

	Dim vID
	Dim vName
	Dim vInfo
	Dim vCode
	Dim LastError

	Private Sub Class_Initialize()
		Call ChkLogin("label")
		Call Initialize()
	End Sub

	Private Sub Class_Terminate()
		Call Initialize()
	End Sub

	Public Function Initialize()
		vID = 0
		vName = ""
		vInfo = ""
		vCode = ""
	End Function

	Public Function GetValue()
		vName = Request.Form("oName")
		vName = Replace(vName," ","")
		vInfo = Request.Form("oInfo")
		vCode = Request.Form("oCode")
		If Len(vInfo) = 0 Then vInfo = vName
		If Len(vName) < 1 Or Len(vName) > 50 Then LastError = "标签代码的长度请控制在 1 至 50 位" : GetValue = False : Exit Function
		If Len(vInfo) > 250 Then LastError = "标签说明的长度请控制在 250 位内" : GetValue = False : Exit Function
		GetValue = True
	End Function

	Public Function SetValue()
		Dim Rs
		Set Rs = DB("Select * From [{pre}Label] Where [ID]=" & vID,1)
		If Rs.Eof Then Rs.Close : Set Rs = Nothing : LastError = "你所需要查询的记录 " & vID & " 不存在!" : SetValue = False : Exit Function
		vName = Rs("Name")
		vInfo = Rs("Info")
		vCode = Rs("Code")
		Rs.Close
		Set Rs = Nothing
		SetValue = True
	End Function

	Public Function Create()
		Dim Rs
		Set Rs = DB("Select [ID] From [{pre}Label] Where [Name]='" & vName & "'",1)
		If Not Rs.Eof Then Rs.Close : Set Rs = Nothing : LastError = "标签代码 的值 " & vName & " 已存在!" : Create = False : Exit Function
		Set Rs = DB("Select * From [{pre}Label]",3)
		Rs.AddNew
		Rs("Name") = vName
		Rs("Info") = vInfo
		Rs("Code") = vCode
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		Create = True
	End Function

	Public Function Modify()
		Dim Rs
		Set Rs = DB("Select * From [{pre}Label] Where [ID]=" & vID,3)
		If Rs.Eof Then Rs.Close : Set Rs = Nothing : LastError = "你所需要更新的记录 " & vID & " 不存在!" : Modify = False : Exit Function
		Rs("Name") = vName
		Rs("Info") = vInfo
		Rs("Code") = vCode
		Rs.Update
		Rs.Close
		Set Rs = Nothing
		Modify = True
	End Function

	Public Function Delete()
		Call SetValue()
		DB "Delete From [{pre}Label] Where [ID]=" & vID ,0
		Delete = True
	End Function

End Class
%>